/* eslint valid-jsdoc: "off" */
'use strict';

/**
 * @param {Egg.EggAppInfo} appInfo app info
 */
module.exports = appInfo => {
  /**
   * built-in config
   * @type {Egg.EggAppConfig}
   **/
  const config = exports = {};

  // use for cookie sign key, should change to your own and keep security
  config.keys = appInfo.name + '_1612511824463_695';

  // 配置需要的中间件，数组的顺序即为中间件加载的顺序
  config.middleware = [
    'forbidIp',
  ];
  // 上面中间件的配置 ip
  config.forbidIp = {
    forbidips: [
      '192.168.1.12',
      // '127.0.0.1',
    ],
  };
  // 渲染模板配置
  config.view = {
    defauleViewEngine: 'nunjucks',
    mapping: {
      '.html': 'nunjucks',
    },
  };
  // 连接数据库
  config.mysql = {
    client: {
      // host
      host: 'localhost',
      // 端口号
      port: '3306',
      // 用户名
      user: 'root',
      // 密码
      password: 'root',
      // 数据库名
      database: 'wfyuan',
    },
    // 是否加载到 app 上，默认开启
    app: true,
    // 是否加载到 agent 上，默认关闭
    agent: false,
  };
  // add your user config here
  const userConfig = {
    // myAppName: 'egg',
  };

  return {
    ...config,
    ...userConfig,
  };
};


